package com.tom;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;

public class MailTester {

	public static void main(String[] args) throws MessagingException, AddressException {
		Properties props = System.getProperties();
		props.put("mail.host", "mail.pccu.edu.tw");
		props.put("mail.transport.protocol", "smtp");
		Session session = Session.getDefaultInstance(props);
		InternetAddress from = new InternetAddress("jack@test.com");
		InternetAddress to = new InternetAddress("neil168.lin@gmail.com");
		Message msg = new MimeMessage(session);
		try {
			msg.setFrom(from);
			msg.setRecipient(Message.RecipientType.TO, to);
			msg.setSubject("mail for testing");
			msg.setText("測試訊息內容");
		} catch (javax.mail.MessagingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
	
